<template>
	<view>
		<view style="padding: 20rpx;">
			<view class="text1">
				请告诉我们想举报{{type=='commit'?'评论':'帖子'}}的原因
			</view>
			<view class="content">
				<view class="item flex_lr" @click="selectPayment(index)" v-for="(item,index) in list" :key="index">
					<view>{{item.type_name}}</view>
					<image class="btn-img1" v-if="selectedItem==index" src="https://pw.qyang.cc/static/commit-success.png" mode=""></image>
					<image class="btn-img1" v-else src="https://pw.qyang.cc/static/selected-null.png" mode=""></image>
				</view>
			</view>
			<view class="content1">
				<u--textarea height="100" border="none" v-model="contentValue" placeholder="请输入举报内容..." count
					maxlength="60"></u--textarea>
			</view>
		</view>
		<view class="bottom">
			<view class="btn" @click="submit()">
				保存
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				selectedItem: null,
				contentValue: '',
				list: [],
				id:null,
				type:''
			};
		},
		onLoad(e) {
			this.id = e.id
			this.type = e.type?e.type:''
			this.rq.getData('dynamic/report_type').then(res=>{
				this.list = res.data
			})
		},
		methods: {
			selectPayment(paymentType) {
				this.selectedItem = paymentType;
			},
			submit() {
				if(this.selectedItem===null){
					uni.showToast({
						title:'请选择举报类型~',
						icon:'none'
					})
					return
				}
				if(!this.contentValue){
					uni.showToast({
						title:'请输入举报内容~',
						icon:'none'
					})
					return
				}
				
				let params = {
					type_id:this.list[this.selectedItem].id,
					content:this.contentValue,
					dynamic_id:this.id,
					type:this.type == 'commit'?2:1
				}
				this.rq.getData('dynamic/report',params).then(res=>{
					if(res.code===1){
						uni.showToast({
							title:'举报成功~',
							icon:'none',
							success() {
								setTimeout(()=>{
									uni.navigateBack()
								},500)
							}
						})
					}
				})				
			}
		}
	}
</script>

<style lang="scss">
	.text1 {
		position: absolute;
		left: 0px;
		top: 0;
		width: 100%;
		height: 70rpx;
		opacity: 1;
		background: #FEF4F5;
		font-family: PingFang SC;
		font-size: 14px;
		font-weight: normal;
		line-height: 38px;
		text-align: center;
		letter-spacing: 0px;
		color: #FF7681;
	}

	.content {
		// width: 341px;
		border-radius: 8px;
		opacity: 1;
		background: #FFFFFF;
		margin-top: 100rpx;
		padding: 10rpx;

		.item {
			// display: flex;
			margin: 20rpx;
			padding: 20rpx 0;

			.img1 {
				width: 14px;
				height: 14px;
				margin-right: 10rpx;
			}

			.btn-img1 {
				width: 16px;
				height: 16px;
				// position: absolute;
				// right: 24px;
			}
		}
	}

	.content1 {
		// width: 351px;
		border-radius: 8px;
		opacity: 1;
		background: #FFFFFF;
		margin: 20rpx auto;
		padding: 20rpx;
	}

	.bottom {
		width: 100%;
		box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.1);
		height: 80rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		bottom: 0;
		padding: 20rpx 0;

		.btn {
			width: 80%;
			height: 70rpx;
			border-radius: 102px;
			background: #FF5866;
			border: 1px solid #FF5866;
			color: #FFFFFF;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>